package com.yundahh.u8c.dao;

import com.yundahh.u8c.config.U8CConfig;
import com.yundahh.u8c.dao.base.U8CBaseDao;
import com.yundahh.u8c.entity.BaseDocParent;
import com.yundahh.u8c.entity.BaseDocVO;
import com.yundahh.u8c.entity.base.U8CResult;
import com.yundahh.u8c.enums.OperationType;
import com.yundahh.u8c.util.JsonUtils;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class BaseDocDao extends U8CBaseDao<BaseDocVO> {



    public BaseDocDao(U8CConfig config) {
        super(config);
    }

    @Override
    public Class<BaseDocVO> getClazz() {
        return BaseDocVO.class;
    }

    @Override
    public String getApiUrl() {
        return "/u8cloud/api/uapbd/invbasdoc";
    }

    public boolean update(BaseDocParent baseDocParent){
        List<BaseDocVO> list =new ArrayList<>();
        list.add(new BaseDocVO());
        list.get(0).setParentvo(baseDocParent);
        String json="{\""+BaseDocVO.aliasName+"\":"+JsonUtils.object2Json(list)+"}";
        System.out.println(json);
        try {
            U8CResult<BaseDocVO> send = send(OperationType.UPDATE, json);
            if(send.getStatus().equals("success"))
                return true;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return false;
    }
}
